'use strict';

    // 设置边框尺寸
    var width = $(window).width();
    var height = $(window).height();

    $('.yc_layout').css('width',width);
    $('.yc_layout').css('height',height);



    // 轮播图部分
    $(function () {
    var _window = window;
    var document = _window.document;
    var navigator = _window.navigator;
    var location = _window.location;
    var $ = _window.jQuery;

    // 初始化轮播图

    $('.slides').slidesjs({
        navigation: {
            active: false,　　//显示或隐藏前一张后一张切换按钮；默认值为true,
            effect: "slide"　　//设置切换的方式，slide:平滑，fade:渐显；默认值slide
        },
        pagination: {
            active: false
        },
        play: {
            active: false,       //开始自动播放功能；默认值true
            interval: 7000,     //在每一个幻灯片上花费的时间；默认值5000
            auto: true,          //开始自动播放；默认值false

        },
        effect: {
            slide: {
                speed: 1000
            }
        },
        callback: {
            loaded: function(number) {
                // console.log(number);
                earn(number);
            },
            complete: function(number) {
                // console.log(number);
                earn(number);
            }
        }
    });

    });

    function earn(number) {
        var id = $('.myimg').eq(number-1).data('id');
        var money =  $('.myimg').eq(number-1).data('price');
        $.ajax({
            url: "/earn",
            data:{id:id},
            type:'post',
            success:function (data) {
                if(data.code == 0){
                    $('.money').text(data.data);
                    setTimeout(function () {
                        $('.tishi').fadeIn();
                    },500);
                    setTimeout(function () {
                        $('.tishi').fadeOut();
                    },1500);

                }
            },
            error:function () {
                console.log('no');
            },
            dataType:'json'
        });
    }

    function show_money(number) {

        console.log(money);
    }